<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo $GMAP_KEY;?>" type="text/javascript"></script>

<div class="places">
<?php 
$path = "content/dane_kontaktowe.xml";
$places = getPlaces($path);
foreach( $places as $p ) {
?>
    <div class="block">
	<div class="top">
        <div class="top-left">&nbsp;</div>
        <div class="top-middle">&nbsp;</div>
        <div class="top-right">&nbsp;</div>
    </div>
	<div class="place">
		<div class="name"><?php echo $p->name;?></div>
		<div class=""><?php echo $p->address;?></div>
		<div class=""><?php echo $p->city.'&nbsp;'.$p->zipcode;?></div>
		 
		<?php foreach($p->phones as $phone){ ?>
		<div class="phone">
    		<div class="label">tel.</div>
            <div class="value"><?php echo $phone;?></div>
        </div>
		<?php } ?>
		<?php foreach($p->faxes as $fax){ ?>
		<div class="phone">
    		<div class="label">fax.</div>
    		<div class="value"><?php echo $fax;?></div>
		</div>
		<?php } ?>
		<div class="link"><a onclick="mapaStart('<?php echo $p->name;?>', '<?php echo $p->fullAddress;?>');">
		    <?php echo $SHOW_ON_MAP;?>&nbsp;&raquo;</a>
		</div>		
	</div>	
	<div class="bottom">
        <div class="bottom-left">&nbsp;</div>
        <div class="bottom-middle">&nbsp;</div>
        <div class="bottom-right">&nbsp;</div>
    </div>
    </div>
<?php     
}
?>
    <div class="block">
	<div class="top">
        <div class="top-left"></div>
        <div class="top-middle"></div>
        <div class="top-right"></div>
    </div>
	<div class="place">		 
		<?php foreach($p->emails as $email){ ?>
		<div class="phone">
		    <div class="label">e-mail:</div>
		    <div class="value"><a href="mailto:<?php echo $email;?>"><?php echo $email;?></a></div>		
		</div>
		<?php } ?>
		<?php foreach($p->ggs as $gg){ ?>
		<div class="phone">
		    <div class="label">gadu-gadu:</div>
		    <div class="value"><?php echo $gg;?></div>
		    <div class="ggimg">
		    <img src="http://status.gadu-gadu.pl/users/status.asp?id=<?php echo $gg;?>&amp;styl=0" alt=""/>
		    </div>
		</div>
		<?php } ?>	
	</div>	
	<div class="bottom">
        <div class="bottom-left"></div>
        <div class="bottom-middle"></div>
        <div class="bottom-right"></div>
    </div>
    </div>
</div>

<div class="map">
	<div class="top">
        <div class="top-left"></div>
        <div class="top-middle"></div>
        <div class="top-right"></div>
    </div>
	<div class="googleMap">
  		<div id="ID_MAPA" class="gMap"></div>
	</div>        
	<div class="bottom">
        <div class="bottom-left"></div>
        <div class="bottom-middle"></div>
        <div class="bottom-right"></div>
    </div>
</div>	

<script type="text/javascript">  
<!--
var geo;
var mapa;

function skoczDoAdresu(nazwa, adres)
{
	if(!geo) return;
	geo.getLatLng(adres,function(punkt)
	{
		if (!punkt)
		{
			//alert(adres + " nie został znaleziony!");
		}
		else
		{
			mapa.panTo(punkt);
			mapa.clearOverlays();
			
			// dodajemy w tym miejscu marker
			var ikona = new GIcon();
			ikona.image='http://maps.google.com/mapfiles/kml/pal3/icon55.png';
			ikona.shadow='';
			ikona.iconSize=new GSize(32,32);
			ikona.iconAnchor=new GPoint(16,16);
			ikona.infoWindowAnchor=new GPoint(16,16);
			
			var marker = new GMarker(punkt,{title: adres});
			mapa.addOverlay(marker);
			marker.openInfoWindowHtml('<strong>' + nazwa + '</strong><br/>' + adres);
		}
	});
}

function mapaStart(nazwa, adres)
{
	if(GBrowserIsCompatible())  
	{
		mapa = new GMap2(document.getElementById("ID_MAPA"),{mapTypes: [G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]});
	    mapa.setCenter(new GLatLng(53.429805, 14.537883), 15);
		
		// kontrolki mapy
		mapa.addControl(new GLargeMapControl());
		var typyMapy = mapa.getMapTypes();    
		typyMapy[0].getName= function() { return "Mapa";}
		typyMapy[1].getName = function() { return "Satelita";}
		typyMapy[2].getName = function() { return "Hybryda";}
		mapa.addControl(new GMapTypeControl());
		//mapa.addControl(new GOverviewMapControl()); 
		//mapa.addControl(new GScaleControl());
		
		// nowy obiekt do geokodowania
	    geo = new GClientGeocoder();

	    skoczDoAdresu(nazwa, adres);
	}
}

mapaStart('<?php if (count($places) > 0) { echo $places[0]->name;}?>','<?php if (count($places) > 0) { echo $places[0]->fullAddress;}?>');
-->
</script>   
